package cn.funeralobjects.ams.web.mapper;

import cn.funeralobjects.ams.entity.EProductApi;
import cn.funeralobjects.ams.model.ProductApi;
import cn.funeralobjects.ams.web.model.MProductApi;
import cn.funeralobjects.ams.web.model.VProductApi;
import cn.funeralobjects.common.web.controller.converter.ModelMapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * @author FuneralObjects
 * Create date: 2020/5/28 6:04 PM
 */
@Mapper(componentModel = "spring", uses = ProductMapper.class)
public interface ProductApiMapper extends ModelMapper<MProductApi, ProductApi, EProductApi, VProductApi> {

    /**
     * entity -> vo
     *
     * @param eProductApi entity
     * @return vo
     */
    @Mappings({
            @Mapping(target = "productId", source = "product.id")
    })
    @Override
    VProductApi toVo(EProductApi eProductApi);

    /**
     * vo -> entity
     *
     * @param vProductApi vo
     * @return entity
     */
    @Mappings({
            @Mapping(target = "product.id", source = "productId")
    })
    @Override
    EProductApi toEntity(VProductApi vProductApi);
}
